package com.zkingsoft.services.bus.impl;

import com.zkingsoft.services.bus.BusCatalogService;
import com.zkingsoft.pojo.PaginationVO;
import com.zkingsoft.model.bus.BusCatalog;
import com.zkingsoft.dao.bus.BusCatalogDao;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.zkingsoft.exception.GlobleException;
import com.zkingsoft.util.ModelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-28 16:55
 */
@Service("busCatalogService")
public class  BusCatalogServiceImpl implements    BusCatalogService  {

	
	@Autowired
	private BusCatalogDao busCatalogDao;
	
	
	@Override
	public int add(BusCatalog busCatalog){
		
		return busCatalogDao.insert(busCatalog);
		
	}
	
	@Override
	public int batchAdd(List<BusCatalog>  busCatalogList) {
		return busCatalogDao.batchInsert(busCatalogList);
	}
	
	
   	
    @Override
	public int modifyByMap(BusCatalog oldBusCatalog
	,BusCatalog newBusCatalog){
	
		if (!ModelUtils.isModified(oldBusCatalog, newBusCatalog)) {
			return 1;
		}
		Map<String, Object> modifyMap=null;
		try {
			modifyMap = ModelUtils.comparePojo2Map(oldBusCatalog, newBusCatalog);
		} catch (Exception e) {
			new GlobleException("数据对比失败");
		}
		if (modifyMap.size() > 0) {
			modifyMap.put("cataId", oldBusCatalog.getCataId());
			busCatalogDao.updateByMap(modifyMap);
		}
		return 1;
	}
	
	@Override
	public int modifyByModel(BusCatalog busCatalog){
	
		return busCatalogDao.updateByModel(busCatalog);
	
	}
	
	
	
	@Override
	public int remove(List<Long> list){
	
		return busCatalogDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long cataId){
	
		return busCatalogDao.deleteById(cataId);
	
	}
	
	@Override
	public int removeByModel(BusCatalog busCatalog){
	
		return busCatalogDao.deleteByModel(busCatalog);
	
	}
	
	
	@Override
	public List<BusCatalog> findInPage(BusCatalog busCatalog,  PaginationVO pageVo){
	
		return busCatalogDao.selectInPage(busCatalog , pageVo);
	
	}
	
	@Override
	public List<BusCatalog> findByModel(BusCatalog busCatalog){
	
		return busCatalogDao.selectByModel(busCatalog);
	
	}
	
	@Override
	public int  findTotal(BusCatalog busCatalog){
	
		return busCatalogDao.selectTotalRecord(busCatalog);
	
	}
	
	@Override
	public BusCatalog  findById(Long cataId){
	
		return busCatalogDao.selectById(cataId);
	
	}

   	
	  
	
}